home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_enscript.idb / usr / freeware / bin / sliceprint.z / sliceprint
Encoding:
Text File  |  1998-10-28  |  2.0 KB  |  81 lines

  1. #!/usr/sbin/perl
  2. # -*- perl -*-
  3. #
  4. # Print documents with long lines.
  5. # Copyright (c) 1996 Markku Rossi
  6. #
  7. # Author: Markku Rossi <mtr@iki.fi>
  8. #
  9.  
  10. #
  11. # This file is part of GNU enscript.
  12. # This program is free software; you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; either version 2, or (at your option)
  15. # any later version.
  16. #
  17. # This program is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. # GNU General Public License for more details.
  21. #
  22. # You should have received a copy of the GNU General Public License
  23. # along with this program; see the file COPYING.  If not, write to
  24. # the Free Software Foundation, 59 Temple Place - Suite 330,
  25. # Boston, MA 02111-1307, USA.
  26. #
  27.  
  28. $enscript = "enscript";
  29.  
  30. $program = $0;
  31. $program =~ s/.*\///g;
  32.  
  33. sub usage {
  34.     warn "Usage: $program [ENSCRIPT_OPTION]... [FILE]...\n";
  35. }
  36.  
  37. # Handle arguments.
  38. $args = "";
  39. $files = "";
  40. while ($arg = shift(@ARGV)) {
  41.     if ($arg eq "--help") {
  42.     &usage;
  43.     exit 0;
  44.     } elsif ($arg eq "--version") {
  45.     warn "sliceprint 1.0\n";
  46.     exit 0;
  47.     } elsif ($arg =~ /^-p(.+)$/
  48.     || $arg =~ /^-o(.+)$/
  49.     || $arg =~ /^--output=(.+)$/) {
  50.     $output_file = $1;
  51.     } elsif ($arg eq "-p" || $arg eq "-o") {
  52.     $output_file = shift(@ARGV);
  53.     } elsif ($arg =~ /^-/) {
  54.     $args .= " $arg";
  55.     } else {
  56.     $files .= " $arg";
  57.     }
  58. }
  59.  
  60. # Check if output file is "-".
  61. if (defined($output_file) && $output_file eq "-") {
  62.     die "$program: output file can't be stdout\n";
  63. }
  64.  
  65. $slice = 0;
  66. while (1) {
  67.     $slice++;
  68.     if (defined($output_file)) {
  69.     $cmd = "$enscript" . $args . " --slice=$slice -p"
  70.         . $output_file . "." . $slice . " " . $files;
  71.     } else {
  72.     $cmd = "$enscript" . $args . " --slice=$slice" . $files;
  73.     }
  74.     print "printing slice $slice...\n";
  75.     $result = `$cmd 2>&1`;
  76.     if ($result !~ ".*lines were.*") {
  77.     last;
  78.     }
  79. }
  80.